<%var body = { var formId = 'updateForm' + object.code; var url = '/form/doUpdate/' + object.code; %>

<form class="layui-form" action="" lay-filter="formQuery">
  <div class="layui-form-item">
    <% for(field in object.fields){ %>
    <div class="layui-inline">
      <label class="layui-form-label">${field.cn}</label>
      <div class="layui-input-inline">
        <input
          type="text"
          name="${field.en}"
          value="${record.uuid}"
          required
          lay-verify="required"
          placeholder="请输入${field.cn}"
          autocomplete="off"
          class="layui-input"
        />
      </div>
    </div>
    <% } %>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script type="text/javascript" src="${STATIC!}/xadmin/lib/layui/layui.all.js"></script>

<script>
  layui.use('form', function () {
  	var form = layui.form;
  	var laydate = layui.laydate;

  	//给表单赋值
  	form.val("formQuery", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
  		<%
  		for (field in object.fields) {
  			var value = record[field.en]; %>
  			"${field.en}": "${value}",
  			<%
  		} %>
  	});

  	//初始赋值
  	laydate.render({
  		elem: '#test5',
  		value: '2019-10-16',
  		isInitValue: true
  	});



  	//监听提交
  	form.on('submit(formDemo)', function (data) {
  		layer.msg(JSON.stringify(data.field));
  		$.post('${url}', data.field, function (result) {
  			if (result.success) {
  				//3.1   弹窗提示
  				layer.msg(('新增${object.name}成功'));
  				//3.2  获得frame索引
  				var index = parent.layer.getFrameIndex(window.name);
  				//3.3   关闭当前frame
  				parent.layer.close(index);
  				//3.4   刷新页面
  				window.parent.location.reload();
  			} else {
  				layer.alert(result.msg);
  			}
  		});
  		return false;
  	});
  });
</script>

<%if(!isEmpty(object.diy_js!)){%>
<script type="text/javascript" src="${object.diy_js}"></script>
<%}%> <%};include("/xfast/layout/default.html",{'title' : 'update' + object.name, 'layoutContent' : body, 'isEditor' :
true}){}%>
